﻿using System.Windows;
using System;
using System.Windows.Controls;
using LibVLCSharp.Shared;

namespace MainCableTest
{
    /// <summary>
    /// DataPage.xaml 的交互逻辑
    /// </summary>
    public partial class DataPage : Page
    {
        private LibVLC _libVLC;
        private MediaPlayer _mediaPlayer;

        public DataPage()
        {
            InitializeComponent();
            Core.Initialize(); // Initialize LibVLC
        }

        private void VideoView_Loaded(object sender, RoutedEventArgs e)
        {
            _libVLC = new LibVLC();
            _mediaPlayer = new MediaPlayer(_libVLC);
            VideoView.MediaPlayer = _mediaPlayer;

            // Replace with your RTSP stream URL
            var media = new Media(_libVLC, new Uri("rtsp://10.60.3.108:554/user=admin&password=&channel=1&stream=0.sdp?"));
            _mediaPlayer.Play(media);
        }

        //protected override void OnClosing(System.ComponentModel.CancelEventArgs e)
        //{
        //    base.OnClosing(e);
        //    _mediaPlayer?.Dispose();
        //    _libVLC?.Dispose();
        //}
    }
}
